#include "stm32f10x.h"
#include "nvic.h"
#include "uart.h"
// Initial NVIC configuration
void NVIC_Configuration(void)
{
	NVIC_InitTypeDef NVIC_InitStructure;

	/* Set the Vector Table base location at 0x08000000 */
	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);


	// Enable and configure the priority of the UART1 Update IRQ Channel
	NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = UART1_INTR_PRI;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);
	
	USART_ClearFlag(USART1, USART_FLAG_CTS | USART_FLAG_LBD |
					USART_FLAG_TC | USART_FLAG_RXNE);
	
	// Enable UART1 interrupts
	USART_ITConfig(USART1,USART_IT_PE  ,ENABLE);      // Parity Error interrupt
	USART_ITConfig(USART1,USART_IT_TC  ,DISABLE);
	USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);      // Receive Data register not empty interrupt
	USART_ITConfig(USART1,USART_IT_IDLE,DISABLE);
	USART_ITConfig(USART1,USART_IT_LBD ,DISABLE);
	USART_ITConfig(USART1,USART_IT_CTS ,DISABLE);
	USART_ITConfig(USART1,USART_IT_ERR ,DISABLE);
	
	
}

